package com.teach.controller;

import com.teach.dto.SeckillGoodsDto;
import com.teach.entity.ResponseEntity;
import com.teach.service.TbSeckillgoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/seckillgoods")
@Api(tags = "秒杀商品的控制层")
public class SeckillGoodsController {
    @Resource
    private TbSeckillgoodsService tbSeckillgoodsService;

    @PostMapping("/addSeckill")
    @ApiOperation("添加秒杀表")
    public ResponseEntity addSeckill(@RequestBody SeckillGoodsDto seckillGoodsDto){
        return tbSeckillgoodsService.addSeckill(seckillGoodsDto);
    }

    @PostMapping("/updateState")
    @ApiOperation("修改审核状态")
    public ResponseEntity updateState(@RequestBody SeckillGoodsDto seckillGoodsDto){
        return tbSeckillgoodsService.updateState(seckillGoodsDto);
    }

    @GetMapping("/addDraw")
    @ApiOperation("添加用户领取优惠券表")
    public ResponseEntity addDraw(@RequestParam(value = "id")Integer id, HttpServletRequest request){
        String token = request.getHeader("token");
        return tbSeckillgoodsService.addDraw(id,token);
    }

}
